import app from '../app.js'


const userInit = () => {
  app.get('/user', (req, res) => {
    res.send({
      code: 200,
      data: {
        data: [{
            id: '10001001',
            userName: '李毅',
            emails: '123@qq.com',
            role: 'R0001'
          },
          {
            id: '10001002',
            userName: '李已',
            emails: '123@qq.com',
            role: 'R0001'
          },
          {
            id: '10001003',
            userName: '李移',
            emails: '123@qq.com',
            role: 'R0001'
          }
        ],
        total: 3
      },
      msg: 'success'
    })
  });

  // 编辑编辑
  app.put('/user', (req, res) => {
    res.send({
      code: 200,
      data: null,
      query: {
        info:req.body
      },
      msg: 'success'
    })
  });

  // 新增用户
  app.post('/user', (req, res) => {
    // 获取POST请求参数
    const postData = req.body;
    res.send({
      code: 200,
      data: null,
      query: {
        info: postData
      },
      msg: 'success'
    })
  });

  // 删除用户
  app.delete('/user/:id', (req, res) => {
    // console.log('user-delete', req.params);
    res.send({
      code: 200,
      data: req.params,
      msg: 'success'
    })
  });
  // 示例：http://localhost:3000/user/U1001


}


export default userInit;